package com.niit.RPCCalculator;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.ipc.RPC;

import java.net.InetSocketAddress;
import java.util.Scanner;

public class CalculatorController {
    public static  void main(String[] args) {
        int result1;
        int result2;
        try {
            com.niit.RPCCalculator.CalculatorServiceInterface proxy = RPC.getProxy(com.niit.RPCCalculator.CalculatorServiceInterface.class,
                    1L,new InetSocketAddress("localhost",1000),new Configuration());

            System.out.println("Enter Number1");

            Scanner sc = new Scanner(System.in);
            int num1 = sc.nextInt();
            System.out.println("Enter Number2");
            int num2 = sc.nextInt();
            result1 = proxy.addNumber(num1,num2);
            System.out.println("Addition of Number is :"+ result1);
            result2 = proxy.subtractNumber(num1,num2);
            System.out.println("Addition of Number is :"+ result2);
        }catch (Exception e){
            System.out.println("Error : " +e.getMessage());
        }
    }
}
